#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int tmp = nums[0];
        vector<int>::iterator it = nums.begin() + 1;
        while (it != nums.end()) {
            if (*it == tmp) {
                it = nums.erase(it);
                continue;
            }
            else {
                tmp = *it;
            }
            ++it;
        }
        return nums.size();
    }
};